#include<iostream>
#include <unistd.h>
#include<signal.h>
#include<sys/wait.h>
using namespace std;



void PrintBlock()
{
    sigset_t set, oset;
    sigemptyset(&set);
    sigemptyset(&oset);

    sigprocmask(SIG_BLOCK, &set, &oset);

    cout<<"block:";
    for(int i = 31; i >0; i--)
    {
        if(sigismember(&oset,i))    cout<<"1";
        else cout<<"0";
    }
    cout<<endl;
    
}
void hander(int signo)
{
    cout<<"我是 "<< signo <<" 信号"<<endl;
    while(1)
    {
        PrintBlock();
        sleep(1);
    }
}
int main()
{
    struct sigaction act, oact;
    act.sa_handler = hander;

    ::sigaction(2, &act, &oact);

    while(1)
    {
        PrintBlock();
        sleep(1);
    }
}
